package com.shuyan.base.algorithm;

import java.text.BreakIterator;

public class MyThread2 implements Runnable {


    public static void main(String[] args) {
        MyThread2 t = new MyThread2();
        Thread t1 = new Thread(t, "线程0");
        Thread t2 = new Thread(t, "线程1");
        t1.start();
//        try {
//            t1.join();
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        t2.start();
    }


    private Object obj = new Object();

    @Override
    public void run() {
        int i = 5;
            while (true) {
                if (i > 0) {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName()+"  "+i--);
                } else {
                    break;

            }
        }
    }
}
